<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<html>
<head>
	<script type="text/javascript" src="scripts/boot.js"></script>
</head>
<body style="border: 0px; margin: 0px; padding: 0px;width: 100%;height: 100%">
	<div class="mini-toolbar" style="border-bottom:0;padding:0px;">
	    <table style="width:auto;">
	        <tr>
	            <td>
					<a class="mini-button" iconCls="icon-edit" onclick="onEditLeave('编辑休假单')">编辑休假单</a>
	            </td>
	        </tr>
	    </table>           
	</div>
	<div class="mini-fit" >
    <div id="datagrid1" class="mini-datagrid " idField="id" pageSize="20"
		url="leave_notby_view.do" 
		style="width:100%;height:100%;" allowCellSelect="true" multiSelect="true">
		<div property="columns">
			<div type="indexcolumn" headerAlign="center">#</div>
			<div field="leaveTypeName" width="100" headerAlign="center" align="center">休假类型</div>
			<div field="startTime" width="100" allowSort="true" headerAlign="center" align="center">休假开始时间</div>
			<div field="endTime" width="100" allowSort="true" headerAlign="center" align="center">休假结束时间</div>
			<div field="days" width="100" headerAlign="center" align="center">休假天数</div>
			<div width="120" headerAlign="center" align="center" renderer="onActionRenderer">相关操作</div>
		</div>
	</div>
	</div>
</body>
</html>
<script type="text/javascript">
	mini.parse();
	var grid = mini.get("datagrid1");
	grid.reload();
	
	function onEditLeave(title) {
		var row = grid.getSelected();
	    if(row){
    		mini.open({
    	   		url: "leave_info_edit.do",
    	   		allowResize:false,
               	title: title, width: 930, height: 430,
               	onload: function () {
                   var iframe = this.getIFrameEl();
                   var data = { row: row };
                   iframe.contentWindow.SetData(data);
          		},
	    	   	ondestroy: function (action) {
	    	   		if(action == 'succ'){
	    	   			mini.showMessageBox({
		                    title: "提示",
		                    showModal:false,
		                    iconCls: "mini-messagebox-info",
		                    message: "申请成功！",
		                    timeout: 3000,
		                    x: 'right',
		                    y: 'bottom'
		                });
		    	   		grid.load();
	    	   		}
                }
         	});
	    }else{
	    	mini.alert("请选择一条记录");
	    }
	}

	function onActionRenderer(e) {
	    var s = "<a href='javascript:seeDetails();'>查看详细</a>";
	    return s;
	}
	
	//查看详情
	function seeDetails() {
	    var row = grid.getSelected();
	    if (row) {
	        mini.open({
	            url: "init_leave_details.do",
	            allowResize:false,
	            title: "休假单信息", width: 500, height: 430,
	            onload: function () {
	                var iframe = this.getIFrameEl();
	                var data = { row: row };
	                iframe.contentWindow.SetData(data);
	            }
	        });
	        
	    }
	}
	
</script>